package com.mxpio.erp.common.inventory.entity;

import com.mxpio.erp.common.technology.entity.ItemGroup;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.Dept;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.math.BigDecimal;

/**
 * @Author : 吴盼盼
 * @Datetime : 2022/10/6 16:20
 * @Desc :
 * @Modor :  Modifytime:
 * @modDesc :
 */
@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_INV_INVENTORY_ITEM")
@Schema(description="盘点单盘点任务明细")
public class InventoryItem  extends BaseEntity {

    private static final long serialVersionUID = 1L;
    @Id
    @Generator
    @Column(name = "ID_", updatable = false)
    @Schema(description = "ID")
    private String id;

    @Column(name = "LINE_NO_", updatable = false)
    @Schema(description = "行号")
    private Integer lineNo;

    @Column(name = "INVENTORY_CODE_", updatable = false)
    @Schema(description = "盘点单号")
    private String inventoryCode;

    @Column(name = "ITEM_CODE_")
    @Schema(description = "物料代码")
    private String itemCode;

    @Column(name = "LOT_NO_")
    @Schema(description = "批次")
    private String lotNo;

    @Column(name = "SUB_LOT_INDEX_")
    @Schema(description = "子批次索引号")
    private String subLotIndex;

    @Column(name = "REGION_CODE_")
    @Schema(description = "所属区域编号")
    @Dict(dicCode = "regionCode" ,dicEntity = WarehouseRegion.class, dicText = "regionName")
    private String regionCode;

    @Column(name = "AREA_CODE_" )
    @Schema(description = "所属库区编号")
    @Dict(dicCode = "areaCode" ,dicEntity = WarehouseArea.class, dicText = "areaName")
    private String areaCode;

    @Column(name = "LOCATION_CODE_", updatable = false)
    @Schema(description = "库位编码")
    @Dict(dicCode = "locationCode" ,dicEntity = WarehouseLocation.class, dicText = "locationName")
    private String locationCode;

    @Column(name = "WH_CODE_")
    @Schema(description = "仓库代码")
    @Dict(dicCode = "whCode" ,dicEntity = Warehouse.class, dicText = "whName")
    private String whCode;

    @Column(name = "QUANTITY_STR_")
    @Schema(description = "盘点展示数量")//明盘时等于库存数据，盲盘时为*
    private String quantityStr;

    @Column(name = "QUANTITY_")
    @Schema(description = "库存数量")
    private BigDecimal quantity;

    @Column(name = "INVENTORY_NUM_")
    @Schema(description = "盘点数量")
    private BigDecimal inventoryNum;

    @Column(name = "DIFF_DESC_")
    @Schema(description = "账实差异")
    private String diffDesc;

    @Column(name = "HANDLE_METHOD_")
    @Schema(description = "处理方式")
    @Dict(dicCode="ERP_INV_INVENTORY_HANDLE_METHOD")
    private String handleMethod;

    /**盈亏数量*/
    @Column(name = "INVENTORY_DIFF_NUM_")
    @Schema(description = "差异数量")
    private BigDecimal inventoryDiffNum;

    @Column(name = "DIFF_REASON_")
    @Schema(description = "差异原因")
    private String diffReason;


    @Column(name = "RESPONSIBLE_UNIT_")
    @Schema(description = "责任单位")
    @Dict(dicCode = "deptCode", dicEntity = Dept.class, dicText = "deptName")
    private String responsibleUnit;


    @Column(name = "MEMO_")
    @Schema(description = "备注")
    private String memo;
    @Column(name = "ITEM_NAME_")
    @Schema(description = "物料名称")
    private String itemName;

    @Column(name = "ITEM_GROUP_CODE_")
    @Schema(description = "物料组")
    @Dict(dicCode="groupCode", dicEntity = ItemGroup.class, dicText = "groupName")
    private String itemGroupCode;

    @Column(name = "ITEM_SPEC_")
    @Schema(description = "物料规格")
    private String itemSpec;

    @Column(name = "UNIT_CODE_")
    @Schema(description = "单位编号")
    @Dict(dicCode="ERP_TECH_UNIT_CODE")
    private String unitCode;

    @Column(name = "DRAWING_NO_")
    @Schema(description = "图号")
    private String drawingNo;

    @Column(name = "PLAN_GENERATE_")
    @Schema(description = "是否由有计划产生")
    @Dict(dicCode = "ERP_COMMON_YESNO")
    private Boolean planGenerate;

    /*public Integer getLineNoAsInt() {
        return Integer.parseInt(lineNo);
    }*/
}
